package com.example.videoweb.service.impl;

import com.example.videoweb.dao.CommentMapper;
import com.example.videoweb.domain.Comment;
import com.example.videoweb.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    @Override
    public boolean insert(Comment comment) {
        return commentMapper.insert(comment) > 0;
    }

    @Override
    public boolean delete(Integer id) {
        return commentMapper.delete(id) > 0;
    }

    @Override
    public Comment selectByPrimaryKey(Integer id) {
        return commentMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Comment> allComment() {
        return commentMapper.allComment();
    }

    @Override
    public List<Comment> videoComment(Integer id) {
        return commentMapper.videoComment(id);
    }

    @Override
    public List<Comment> getByContent(String content) {
        return commentMapper.getByContent("%"+content+"%");
    }

    @Override
    public boolean praiseUp(Integer id) {
        return commentMapper.praiseUp(id) > 0;
    }

    @Override
    public boolean praiseDown(Integer id) {
        return commentMapper.praiseDown(id) > 0;
    }
}
